﻿//===============================================================================
// TREASURY MANAGMENT INFORMATION SYSTEMS 
// User Management
//===============================================================================
// Copyright © TIMS GROUP. 2008
//===============================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace APPLICATION.DataAccess
{
    class dbUsers
    {

        // AddEditIUsers

        public void insertUpdateDeleteUsers(int Action, String UserID, int StaffID, 
            String UserN, String Description,bool Spend,String Psw)
        {
            /*
                [UserID] [char](10) 
	            [StaffID] [int] NOT NULL,
	            [UserN] [varchar](20) NOT NULL,
	            [Description] [nvarchar](50) NULL,
	            [Spend] [bit] NULL,
	            [DateES] [sql_variant] NULL,
	            [DateEE] [sql_variant] NULL,
	            [DateSS] [sql_variant] NULL,
	            [DateSE] [sql_variant] NULL,
	            [Psw] [varbinary](max) NULL,                        
           */

            SqlConnection connection = new SqlConnection(globals.APPCONNSTRING);

            SqlCommand command = new SqlCommand();
            command.Connection = connection;

            command.CommandText = "tsp_stUsers";
            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add("@Action", SqlDbType.TinyInt).Value = Action;// ActionID insert update delete
            command.Parameters.Add("@UserID", SqlDbType.Char, 9).Value = UserID;
            command.Parameters.Add("@StaffID", SqlDbType.Int).Value = StaffID;
            command.Parameters.Add("@UserN", SqlDbType.VarChar,20).Value = UserN;
            command.Parameters.Add("@Description", SqlDbType.NVarChar, 50).Value = Description;
            command.Parameters.Add("@Spend", SqlDbType.Bit).Value = Spend;
           // command.Parameters.Add("@Psw", SqlDbType.VarBinary).Value = Psw;


            connection.Open();
            command.ExecuteNonQuery(); //Should be removed in Try-Catch block ! Leaved for testing 

                try
                {
          
                }
                catch (Exception ex)
                {

                }


            connection.Close();

        }
   
       

    }
}
